package edu.mapi.aamas.operator;

import java.awt.Color;

import jade.core.Agent;

import javax.swing.JFrame;

import edu.mapi.aamas.behaviors.StateChangeListener;
import edu.mapi.aamas.behaviors.UpdateState;
import edu.mapi.aamas.common.VehicleState;
import edu.mapi.aamas.common.WorldState;

/**
 * @author ZP
 */
public class OperatorAgent extends Agent implements StateChangeListener {

	private UpdateState updater = new UpdateState();
	private WorldState worldState = updater.getWorld();
	private OperatorInterface opInterface = new OperatorInterface(this);
	protected void setup() {
		super.setup();
		
		updater.addStateChange(this);
		addBehaviour(updater);
		
		JFrame frame = new JFrame("WorldRenderer 2D");
		frame.setSize(800, 600);
		frame.getContentPane().add(opInterface);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public void receiveMessage(VehicleState state) {
		worldState = updater.getWorld();
		opInterface.getR2d().setState(worldState);
	}
	
	public void appendMessage(String message, Color type) {
		opInterface.appendMessage(message, type);
	}
}
